package com.Venue.service;

import com.Venue.entity.Venue;
import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 场地信息 业务逻辑接口
 */
@Service
public interface VenueService {

    /**
     * 添加场地信息
     * @param venue
     * @return
     */
    @CircuitBreaker(name = "venueService", fallbackMethod = "addVenueFallback")
    boolean doAddVenueInfo(Venue venue);

    /**
     * 修改场地信息
     * @param venue
     * @return
     */
    @CircuitBreaker(name = "venueService", fallbackMethod = "modifyVenueFallback")
    boolean doModifyVenueInfo(Venue venue);

    /**
     * 删除场地信息
     * @param venue
     * @return
     */
    @CircuitBreaker(name = "venueService", fallbackMethod = "deleteVenueFallback")
    boolean doDeleteVenueInfo(Venue venue);

    /**
     * 获取场地信息
     * @param venue
     * @return
     */
    @CircuitBreaker(name = "venueService", fallbackMethod = "getVenueInfoFallback")
    Venue doGetVenueInfo(Venue venue);

    /**
     * 获取场地列表
     * @return
     */
    @CircuitBreaker(name = "venueService", fallbackMethod = "getVenueInfoListFallback")
    List<Venue> doGetVenueInfoList();
    /**
     * 查询场地列表
     * @param venue
     * @return
     */
    @CircuitBreaker(name = "venueService", fallbackMethod = "queryVenueInfoListFallback")
    List<Venue> doQueryVenueInfoList(Venue venue);

    // 定义 fallback 方法（添加详细日志）
    default boolean addVenueFallback(Venue venue, Throwable t) {
        System.err.println("【Service熔断】添加场地降级：" + t.getClass().getName() + " - " + t.getMessage());
        t.printStackTrace();
        return false;
    }

    default boolean modifyVenueFallback(Venue venue, Throwable t) {
        System.err.println("【Service熔断】修改场地降级：" + t.getClass().getName() + " - " + t.getMessage());
        return false;
    }

    default boolean deleteVenueFallback(Venue venue, Throwable t) {
        System.err.println("【Service熔断】删除场地降级：" + t.getClass().getName() + " - " + t.getMessage());
        return false;
    }

    default Venue getVenueInfoFallback(Venue venue, Throwable t) {
        System.err.println("【Service熔断】获取场地降级：" + t.getClass().getName() + " - " + t.getMessage());
        return null;
    }

    default List<Venue> getVenueInfoListFallback(Throwable t) {
        System.err.println("【Service熔断】获取列表降级：" + t.getClass().getName() + " - " + t.getMessage());
        return null;
    }

    default List<Venue> queryVenueInfoListFallback(Venue venue, Throwable t) {
        System.err.println("【Service熔断】查询列表降级：" + t.getClass().getName() + " - " + t.getMessage());
        return null;
    }
}